package cn.tedu.boot43.mapper;

import cn.tedu.boot43.entity.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface ProductMapper {
    //全表插入格式:insert into 表名  values (值1,值2);
    @Insert("insert into product values(null,#{title},#{price},#{saleCount})")
    void insert(Product product);
    @Select("select * from product")
    @Result(property = "saleCount",column = "sale_count")
    List<Product> select();
    //删除数据格式:delete from 表名 where 条件
    @Delete("delete from product where id=#{id}")
    void deleteById(int id);
    @Select("select * from product where id=#{id}")
    //column 列
    @Result(property = "saleCount",column = "sale_count")
    Product selectById(int id);
    //修改数据格式:update 表名 set 字段名=值 where 条件
    @Update("update product set title=#{title},price=#{price},sale_count=#{saleCount} where id=#{id}")
    void update(Product product);
}
